class Solution:
    def removeNthFromEnd(self , head , k ):
        # write code here
        # 双指针 一个先走 一个后走
        # 指针先后有影响啊
        p1 = head
        p2 = head
        for i in range(k):
            p2 = p2.next
        if not p2:
            return head.next
        while p2.next:
            p1 = p1.next
            p2 = p2.next
        p1.next = p1.next.next if p1.next.next else None
        return head